/******************************************************************************************************************
* File:Plumber.java
* Course: 17655
* Project: Assignment 1
* Copyright: Copyright (c) 2003 Carnegie Mellon University
* Versions:
*	1.0 November 2008 - Sample Pipe and Filter code (ajl).
*
* Description:
*
* This class serves as an example to illustrate how to use the PlumberTemplate to create a main thread that
* instantiates and connects a set of filters. This example consists of three filters: a source, a middle filter
* that acts as a pass-through filter (it does nothing to the data), and a sink filter which illustrates all kinds
* of useful things that you can do with the input stream of data.
*
* Parameters: 		None
*
* Internal Methods:	None
*
******************************************************************************************************************/

public class Plumber
{
   public static void main( String argv[])
   {
	   //CHANGE: Added line below to assist debugging
	   System.out.println("Sample C Plumber");
		/****************************************************************************
		* Here we instantiate three filters.
		****************************************************************************/

		SourceFilter source = new SourceFilter("SubSetA.dat");
		SourceFilter source2 = new SourceFilter("SubSetB.dat");
	   	//TestSourceFilter source = new TestSourceFilter (1);
	   	//TestSourceFilter source2 = new TestSourceFilter (2);
		MergeFilter merge = new MergeFilter();
		//ConverterFilter converter = new ConverterFilter();
		
		/*
		Argument[] args = new Argument[]{
				new Argument(Measurement.PRESSURE, RelationalOperator.GREATER_THAN, 65.0),
				new Argument(Measurement.PRESSURE, RelationalOperator.GREATER_THAN, 10.0)
		};
		*/
		CorrectorFilter corrector = new CorrectorFilter("Wildpoints.dat", 45.0, 90.0);
		
		/*
		Argument[] args2 = new Argument[]{
				new Argument(Measurement.PRESSURE, RelationalOperator.GREATER_THAN, 65.0),
				new Argument(Measurement.PITCH, RelationalOperator.GREATER_THAN, 10.0)
		};
		*/
		PitchPressureCorrectorFilter ppCorrector = new PitchPressureCorrectorFilter("Rejected.dat",10.0,65.0);
		WriteFilter writer = new WriteFilter("OutputC.dat");

		/****************************************************************************
		* Here we connect the filters starting with the sink filter (Filter 1) which
		* we connect to Filter2 the middle filter. Then we connect Filter2 to the
		* source filter (Filter3).
		****************************************************************************/
		
		writer.Connect(ppCorrector);
		ppCorrector.Connect(corrector); // This essentially says, "connect Filter3 input port to Filter2 output port
		corrector.Connect(merge); // This essentially says, "connect Filter2 input port to Filter1 output port
		merge.Connect2(source2);
		merge.Connect(source);
		
		/****************************************************************************
		* Here we start the filters up. All-in-all,... its really kind of boring.
		****************************************************************************/

		writer.start();
		ppCorrector.start();
		corrector.start();
		//converter.start();
		
		merge.start();
		source2.start();
		source.start();
		

   } // main

} // Plumber